import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import LogIn from '../views/login/index.vue'
import Home from '../views/home.vue'
import EChartsView from '../components/EchartsView.vue'
import PermissionList from '../components/PermissionList.vue'
import UserOne from '../components/UserOne.vue'
import UserList from '../components/UserList.vue'
import UserUpdate from '../components/UserUpdate.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/login',
    name: 'login',
    component: LogIn
  },
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/home',
    name: 'home',
    component: Home,
    redirect:'/echarts',
    children: [
      {
        path: '/echarts',
        name: 'echarts',
        component: EChartsView,
        meta: {
          title: "数据展示"
        }
      },
      {
        path: '/permissionlist',
        name: 'permissionlist',
        component: PermissionList,
        meta: {
          title: "权限列表"
        }
      },
      {
        path: '/user',
        name: 'user',
        component: UserOne,
        redirect: "/userlist",
        meta: {
          title: "住户信息"
        },
        children: [
          {
            path: '/userlist',
            name: 'userlist',
            component: UserList,
            meta: {
              classifyTitle: "用户信息",//分类标题
              title: "住户列表"
            }
          },
          {
            path: '/userupdate',
            name: 'userupdate',
            component: UserUpdate,
            meta: {
              classifyTitle: "用户信息",//分类标题
              title: "住户信息修改"
            }
          }
        ]
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
